/// [Sum square difference](https://projecteuler.net/problem=6)
fn main() {
    for num in &[10, 100] {
        println!(
            "First {} natural numbers, the difference is {}",
            num,
            sum_square_difference(*num)
        );
    }
}
/// (a+b+c)^2 - a^2 -b^2 - c^2 = a(b+c) + b(a+c) + c*(a+b)
fn sum_square_difference(length: u32) -> u32 {
    let buf = (length + 1) * length / 2;
    (1..=length).fold(0, |sum, x| sum + x * (buf - x))
}
